from lxml import etree
from selenium import webdriver
from time import sleep
"""
22空信 罗阳
基本汇率

"""
def getData():
# 获取到edge浏览对象
    edge = webdriver.Edge("C:\Program Files (x86)\Microsoft\Edge\Application\msedgedriver.exe")
# 获取数据页面的数据
    url = "https://quote.eastmoney.com/center/gridlist.html#forex_basic"
# edge浏览器解析地址
    edge.get(url)
    sleep(10)
# 获取页面中的资源
    page = edge.page_source
# 将页面资源解析成html文件
    html = etree.HTML(page)
    name = html.xpath("//tr/td[3]//text()")
    namet = html.xpath("//tr/td[3]//@title")
    i = 0
    for title in name:
        if "..." in title:
            title = namet[i]
            i = i + 1
            print(title)
        else:
            print(title)
    for start_num in range(4,11):
        data = html.xpath(f"//tr/td[{start_num}]//text()")
        print(data)

# 人民币品种url1:  https://quote.eastmoney.com/center/gridlist.html#forex_cny
# 基本汇率url2:  https://quote.eastmoney.com/center/gridlist.html#forex_basic
# 交叉汇率url3:  https://quote.eastmoney.com/center/gridlist.html#forex_cross

if __name__ == '__main__':
    getData()
